#include "ThreadPool.h"
#include <time.h>
#include <unistd.h>
#include <iostream>

using std::cout;
using std::endl;

void func()
{
    ::srand(time(NULL));
    cout << rand() % 100 << endl;
    ::sleep(1);
}

int main(int argc, char* argv[])
{
    tp::ThreadPool threadpool(10, 2);
    threadpool.start();

    int cnt = 20;
    while(cnt--)
    {
        threadpool.addTask(std::bind(func));//生产者角色
        cout << "cnt = " << cnt << endl;
    }

    threadpool.stop();
    return 0;
}
